//
//  XCAPIManager.h
//  MVVM-ViewModel-NetWork-Model
//
//  Created by 刘小椿 on 16/6/17.
//  Copyright © 2016年 刘小椿. All rights reserved.
//

#import "XCBaseModel.h"
#import <ReactiveCocoa/ReactiveCocoa.h>
#import "XCBaseModel.h"

NS_ASSUME_NONNULL_BEGIN

static const NSUInteger kXCAPITimeout = 5;

typedef NS_ENUM(NSUInteger,XCAPIError){
    kXPAPIErrorOther = 0,
    kXCAPIErrorUnKnow = 200, /**< 客户端请求成功>*/
    kXCAPIErrorBadRequest = 400, /**< 客户端请求有语法错误，不能被服务器所理解 */
    kXCAPIErrorUnauthorized = 401, /**< 请求未经授权，这个状态代码必须和WWW-Authenticate报头域一起使用 */
    kXCAPIErrorForbidden = 403, /**< 服务器收到请求，但是拒绝提供服务 */
    kXCAPIErrorNotFound = 404, /**< 请求资源不存在 */
    kXCAPIErrorInternalServerError = 500,  /**< 服务器发生不可预期的错误 */
    kXCAPIErrorServerUnavailable = 503, /**< 服务器当前不能处理客户端的请求，一段时间后可能恢复正常 */
    
};

@interface XCAPIManager : XCBaseModel

- (nonnull RACSignal *)rac_GET:(NSString *)path parameters:(id)parameters;

- (nonnull RACSignal *)rac_POST:(NSString *)path parameters:(id)parameters;

- (nonnull RACSignal *)rac_PUT:(nonnull NSString *)path parameters:(nullable id)parameters;

- (nonnull RACSignal *)rac_DELETE:(nonnull NSString *)path parameters:(nullable id)parameters;

- (nonnull RACSignal *)rac_PATCH:(nonnull NSString *)path parameters:(nullable id)parameters;

@end

@interface XCAPIManager (Restful)

- (RACSignal *)rac_MappingForClass:(Class)class dictionary:(NSDictionary *)dictionary;

- (RACSignal *)rac_MappingForClass:(Class)class array:(NSArray *)array;

- (nonnull RACSignal *)rac_MergeMappingForClass:(nonnull Class)class dictionary:(nonnull NSDictionary *)dictionary;

@end

NS_ASSUME_NONNULL_END
